package org.zhenggn.designpattern.chain;

import com.google.gson.Gson;

/**
 * Created by zhenggn on 2017/5/3.
 */
public class ProjectManager extends Handler {
    public String handleFeeRequest(String user, double fee) {

        System.out.println("====================================== ProjectManager start ======================================");

        Context context = MyThreadLocal.get();

        System.out.println("str is:"+context.getStr());

        System.out.println(new Gson().toJson(context.getUser()));

        String str = "";
        if (fee < 500) {
            if ("小李".equals(user)) {
                str = "项目经理同意" + user + "聚餐费用" + fee + "元的请求";
            } else {
                str = "项目经理不同意" + user + "聚餐费用" + fee + "元的请求";
            }
        } else {
            if (this.getSuccessor() != null) {
                return this.getSuccessor().handleFeeRequest(user, fee);
            }
        }

        System.out.println("====================================== ProjectManager end ======================================");

        return str;
    }
}
